home *** CD-ROM | disk | FTP | other *** search
- #ifndef MSC
-
- /* Non-MSC Version */
-
- #if (defined(M_I86CM) || defined(M_I86LM) || defined(M_I86HM))
-
- /* NOTE: This procedure should only be used for
- large data model programs (i.e., Compact, Large, Huge) */
-
- #include <stddef.h>
- #include "alloc.h"
-
- extern ATABLE AllocationTable [] ; /* Provide storage for block pointers */
- extern SUNIT MBSize ; /* Default allocation block size */
- extern SUNIT NEntry ; /* Number of table entries */
- extern size_t _asizds ; /* Size of default data segment */
- extern size_t _abrktb [] ; /* MSC segment allocation table */
- extern size_t _psp ; /* Segment start of program */
-
- ProgSize ( codesize, dataused, dataallocated, allocused, allocated)
-
- long *codesize ; /* Code Size ( bytes ) */
- long *dataused ; /* Data Size Used ( bytes ) */
- long *dataallocated ; /* Data Size Allocated ( bytes ) */
- long *allocused ; /* Memory Allocation Used ( bytes ) */
- long *allocated ; /* Memory Allocated ( bytes ) */
-
- /*
- +---------------------------------------------------+
- | |
- | This procedure attempts to determine the current |
- | size of the program (in bytes). 'Code' refers |
- | to the actual executable code. 'Data' refers |
- | to the default data segment (note: the data |
- | size allocated can be controlled by setting |
- | using the /max parameter on exemod (normally, |
- | it is set to 65530 bytes). The allocation |
- | parameters refer to memory allocated via malloc |
- | calloc, realloc, etc. |
- | |
- +---------------------------------------------------+
- */
-
- {
- int i ;
- SUNIT *hptr ;
- SUNIT j , bsize ;
-
-
- *codesize = 16L * ( (long) _abrktb [1] - (long) _psp ) ;
- *dataused = (long) _abrktb [0] ;
- *dataallocated = (long) _asizds ;
- *allocused = 0L ;
- *allocated = 0L ;
-
- for ( i = 0 ; i < NEntry ; i++ ) {
- *allocated += (long) AllocationTable [i].Size ;
- j = (SUNIT) sizeof (HEADER) ;
- while ( j < AllocationTable[i].Header->BytesUsed ) {
- hptr = (SUNIT *) AllocationTable [i].Header + j/SSIZE ;
- bsize = *hptr & ~FREE ;
- j += bsize+SSIZE ;
- if ( ! (*hptr & FREE) )
- *allocused += (long) bsize ;
- } ;
- } ;
- }
- #endif
- #else
-
- /* MSC Version */
-
- #include <stddef.h>
- #include <malloc.h>
-
- extern size_t _abrktb [] ;
- extern size_t _asegh ;
- extern size_t _psp ;
- extern size_t _asizds ;
-
- ProgSize ( codesize, dataused, dataallocated, allocused, allocated)
-
- long *codesize ; /* Code Size ( bytes ) */
- long *dataused ; /* Data Size Used ( bytes ) */
- long *dataallocated ; /* Data Size Allocated ( bytes ) */
- long *allocused ; /* Memory Allocation Used ( bytes ) */
- long *allocated ; /* Memory Allocated ( bytes ) */
-
- /*
- +---------------------------------------------------+
- | |
- | This procedure attempts to determine the current |
- | size of the program (in bytes). 'Code' refers |
- | to the actual executable code. 'Data' refers |
- | to the default data segment (note: the data |
- | size allocated can be controlled by setting |
- | using the /max parameter on exemod (normally, |
- | it is set to 65530 bytes). The allocation |
- | parameters refer to memory allocated via malloc |
- | or calloc. |
- | |
- +---------------------------------------------------+
- */
-
- {
- int i ;
- _HEAPINFO hinfo ;
-
- *codesize = 16L * ( (long) _abrktb [1] - (long) _psp ) ;
- *dataused = (long) _abrktb [0] ;
- *dataallocated = (long) _asizds ;
- *allocused = 0L ;
- *allocated = 0L ;
-
- for ( i = 2 ; _abrktb [i] != 0 && _abrktb [i+1] <= _asegh ; i += 2 )
- *allocated += (long) _abrktb [i] ;
-
- hinfo._pentry = NULL ;
- while ( _heapwalk ( &hinfo ) == _HEAPOK )
- if ( hinfo._useflag == _USEDENTRY )
- *allocused += (long) hinfo._size ;
- return ;
- }
- #endif
-